#!/usr/bin/python
# -*- coding: UTF-8 -*-

import MySQLdb
import demjson
import json

def generate_namedtuple(cur):
    from collections import namedtuple
    fieldnames = [d[0].lower() for d in cur.description]
    Record = namedtuple('Record', fieldnames)
    rows = cur.fetchall()
    if not rows:return
    else:
        return map(Record._make, rows)

json = '{"channel":"供应商渠道修改","channelId":"402811a858fc81e10158fca701fd0006","contractAmount":"67676","executeEndDate":"2017-03-08 ","executeStartDate":"2017-02-24 ","finalChannel":"供应商渠道修改","finalChannelId":"402811a858fc81e10158fca701fd0006","id":"402811a8591f56bd0159204c871d004b","isNormal":"是","relContractCode":"","signedCompany":"鑫车投资（上海）有限公司","signedDept":"易鑫资本-人力资源中心-招聘交付组","signedDeptId":"1000002","signedUser":"陈师","signedUserId":"chenshi"}'
text = demjson.decode(json)
print  text
if 'channel' in text :
    channel = text['channel']
    text.pop('channel')
if 'channelId' in text :
    channelId = text['channelId']
    text.pop('channelId')
if 'contractAmount' in text :
    contractAmount = text['contractAmount']
    text.pop('contractAmount')
if 'executeEndDate' in text :
    executeEndDate = text['executeEndDate']
    text.pop('executeEndDate')
if 'executeStartDate' in text :
    executeStartDate = text['executeStartDate']
    text.pop('executeStartDate')
if 'id' in text :
    id = text['id']
    text.pop('id')
if 'incomeSureType' in text :
    incomeSureType = text['incomeSureType']
    text.pop('incomeSureType')
if 'incomeType' in text :
    incomeType = text['incomeType']
    text.pop('incomeType')
if 'isNormal' in text :
    isNormal = text['isNormal']
    text.pop('isNormal')
if 'isReturn' in text :
    isReturn = text['isReturn']
    text.pop('isReturn')
if 'relContractCode' in text :
    relContractCode = text['relContractCode']
    text.pop('relContractCode')
if 'signedCompany' in text :
    signedCompany = text['signedCompany']
    text.pop('signedCompany')
if 'signedDept' in text :
    signedDept = text['signedDept']
    text.pop('signedDept')
if 'signedDeptId' in text :
    signedDeptId = text['signedDeptId']
    text.pop('signedDeptId')
if 'signedUser' in text :
    signedUser = text['signedUser']
    text.pop('signedUser')
if 'signedUserId' in text :
    signedUserId = text['signedUserId']
    text.pop('signedUserId')

print  text

json_filter =  demjson.encode(text)
print json_filter